\hypertarget{nlb-driver_8c}{
\section{Referência ao ficheiro nlb-driver.c}
\label{nlb-driver_8c}\index{nlb-driver.c@{nlb-driver.c}}
}
Arquivo main do L2LB. 

{\tt \#include $<$linux/kernel.h$>$}\par
{\tt \#include $<$linux/module.h$>$}\par
{\tt \#include $<$linux/init.h$>$}\par
{\tt \#include $<$linux/skbuff.h$>$}\par
{\tt \#include $<$linux/netfilter\_\-ipv4.h$>$}\par
{\tt \#include $<$linux/ip.h$>$}\par
{\tt \#include $<$linux/in.h$>$}\par
{\tt \#include $<$linux/if\_\-ether.h$>$}\par
{\tt \#include $<$linux/inetdevice.h$>$}\par
{\tt \#include $<$linux/netdevice.h$>$}\par
{\tt \#include $<$linux/etherdevice.h$>$}\par
{\tt \#include $<$linux/vmalloc.h$>$}\par
{\tt \#include $<$linux/kthread.h$>$}\par
{\tt \#include $<$linux/delay.h$>$}\par
{\tt \#include $<$linux/net.h$>$}\par
{\tt \#include $<$linux/socket.h$>$}\par
{\tt \#include $<$linux/errno.h$>$}\par
{\tt \#include $<$linux/types.h$>$}\par
{\tt \#include $<$linux/moduleparam.h$>$}\par
{\tt \#include \char`\"{}utils.h\char`\"{}}\par
{\tt \#include \char`\"{}cluster.h\char`\"{}}\par
{\tt \#include \char`\"{}hash-afinidades.h\char`\"{}}\par
{\tt \#include \char`\"{}socket.h\char`\"{}}\par
{\tt \#include \char`\"{}heartbeat.h\char`\"{}}\par
{\tt \#include \char`\"{}thread.h\char`\"{}}\par
{\tt \#include \char`\"{}interface.h\char`\"{}}\par
{\tt \#include \char`\"{}netfilter.h\char`\"{}}\par
\subsection*{Funções}
\begin{CompactItemize}
\item 
int \hyperlink{nlb-driver_8c_a6bb443824ee776be4a7a888f204b1d2}{dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new} (struct sk\_\-buff $\ast$skb, struct net\_\-device $\ast$\hyperlink{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}{dev})
\begin{CompactList}\small\item\em Wrapper do metodo dev.hard\_\-start\_\-xmit\_\-old() implementado pelo driver rede responsavel por enviar o pacote de rede. \item\end{CompactList}\item 
static int \hyperlink{nlb-driver_8c_58c1436a949928f231d221233cd6c274}{nlb\_\-init\_\-module} (void)
\begin{CompactList}\small\item\em Incializa o modulo do kernel. \item\end{CompactList}\item 
static void \hyperlink{nlb-driver_8c_252459a2361783e1bd1da46b46c2bdf6}{nlb\_\-exit\_\-module} (void)
\begin{CompactList}\small\item\em Desregistra o modulo. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variáveis}
\begin{CompactItemize}
\item 
static char \hyperlink{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}{dev} \mbox{[}9\mbox{]}
\begin{CompactList}\small\item\em Interface de rede do \hyperlink{structcluster}{cluster} que sera gerenciada pelo L2LB. \item\end{CompactList}\item 
static char \hyperlink{nlb-driver_8c_c8f175c78fae68f5348eab7bcc8ca54b}{ip} \mbox{[}17\mbox{]}
\begin{CompactList}\small\item\em IP virtual do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\end{CompactItemize}


\subsection{Descrição detalhada}
Arquivo main do L2LB. 

Este arquivo eh responsavel por registrar/desregistrar o modulo no kernel do linux 

Definido no ficheiro \hyperlink{nlb-driver_8c-source}{nlb-driver.c}.

\subsection{Documentação das funções}
\hypertarget{nlb-driver_8c_a6bb443824ee776be4a7a888f204b1d2}{
\index{nlb-driver.c@{nlb-driver.c}!dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new@{dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new}}
\index{dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new@{dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new}!nlb-driver.c@{nlb-driver.c}}
\subsubsection[dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new]{\setlength{\rightskip}{0pt plus 5cm}int dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new (struct sk\_\-buff $\ast$ {\em skb}, \/  struct net\_\-device $\ast$ {\em dev})}}
\label{nlb-driver_8c_a6bb443824ee776be4a7a888f204b1d2}


Wrapper do metodo dev.hard\_\-start\_\-xmit\_\-old() implementado pelo driver rede responsavel por enviar o pacote de rede. 

Este metodo remonta o cabecalho do pacote na camada de enlace para os pacotes que estao sendo enviados pela interface de rede do \hyperlink{structcluster}{cluster}.

No L2LB, o cabecalho do pacote da resposta na camada de enlace tem como remetente outra interface de rede, que nao a interface de rede do \hyperlink{structcluster}{cluster}, por onde a requisicao foi recebida. Isto eh necessario para impedir que os swicths de rede apredam uma rota para o IP virtual do \hyperlink{structcluster}{cluster}, uma vez que o IP virtual do \hyperlink{structcluster}{cluster} eh compartilhado por varias maquinas na LAN. Desta forma todos os servidores do \hyperlink{structcluster}{cluster} sempre receberao todas as mensagem enderecadas para o seu IP virtual.

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em skb}]Pacote \item[{\em dev}]Interface de rede \end{description}
\end{Desc}


Definido na linha 80 do ficheiro nlb-driver.c.

Referências cluster::hard\_\-start\_\-xmit\_\-old, cluster::mac\_\-response e my\_\-cluster.

Referenciado por nlb\_\-init\_\-module().\hypertarget{nlb-driver_8c_252459a2361783e1bd1da46b46c2bdf6}{
\index{nlb-driver.c@{nlb-driver.c}!nlb\_\-exit\_\-module@{nlb\_\-exit\_\-module}}
\index{nlb\_\-exit\_\-module@{nlb\_\-exit\_\-module}!nlb-driver.c@{nlb-driver.c}}
\subsubsection[nlb\_\-exit\_\-module]{\setlength{\rightskip}{0pt plus 5cm}static void nlb\_\-exit\_\-module (void)\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{nlb-driver_8c_252459a2361783e1bd1da46b46c2bdf6}


Desregistra o modulo. 



Definido na linha 130 do ficheiro nlb-driver.c.

Referências hash\_\-exit(), nlb\_\-cluster\_\-exit(), nlb\_\-netfilter\_\-exit() e nlb\_\-thread\_\-exit().\hypertarget{nlb-driver_8c_58c1436a949928f231d221233cd6c274}{
\index{nlb-driver.c@{nlb-driver.c}!nlb\_\-init\_\-module@{nlb\_\-init\_\-module}}
\index{nlb\_\-init\_\-module@{nlb\_\-init\_\-module}!nlb-driver.c@{nlb-driver.c}}
\subsubsection[nlb\_\-init\_\-module]{\setlength{\rightskip}{0pt plus 5cm}static int nlb\_\-init\_\-module (void)\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{nlb-driver_8c_58c1436a949928f231d221233cd6c274}


Incializa o modulo do kernel. 

Esta funcao eh responsavel por:\begin{itemize}
\item Inicializar o \hyperlink{structcluster}{cluster}. \hyperlink{cluster_8h_33d0ab81e5ab7cf05146cead194236b7}{init\_\-cluster()}\item Inicializar a interface com o modulo atraves do sistema de arquivo $\backslash$proc. \hyperlink{interface_8h_65a3f35a0907ebf967e1f54265516827}{init\_\-proc\_\-interface()}\item Inicializar a tabela de afinidades. \hyperlink{hash-afinidades_8h}{hash-afinidades.h}\item Inicializar um thread para comunicacao entre os servidores do \hyperlink{structcluster}{cluster}. \hyperlink{thread_8h}{thread.h}\item Inicializar os HOOKS do Netfilter. \hyperlink{netfilter_8h_bf19d764f0af6d861e95cb83707589a7}{nlb\_\-netfilter\_\-init()} \end{itemize}


Definido na linha 100 do ficheiro nlb-driver.c.

Referências dev, dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new(), hash\_\-init(), init\_\-cluster(), init\_\-proc\_\-interface(), ip, cluster::mac\_\-response, my\_\-cluster, nlb\_\-netfilter\_\-init(), nlb\_\-thread\_\-init() e printk\_\-mac\_\-addr().

\subsection{Documentação das variáveis}
\hypertarget{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}{
\index{nlb-driver.c@{nlb-driver.c}!dev@{dev}}
\index{dev@{dev}!nlb-driver.c@{nlb-driver.c}}
\subsubsection[dev]{\setlength{\rightskip}{0pt plus 5cm}char {\bf dev}\mbox{[}9\mbox{]}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}


Interface de rede do \hyperlink{structcluster}{cluster} que sera gerenciada pelo L2LB. 



Definido na linha 51 do ficheiro nlb-driver.c.

Referenciado por nlb\_\-init\_\-module().\hypertarget{nlb-driver_8c_c8f175c78fae68f5348eab7bcc8ca54b}{
\index{nlb-driver.c@{nlb-driver.c}!ip@{ip}}
\index{ip@{ip}!nlb-driver.c@{nlb-driver.c}}
\subsubsection[ip]{\setlength{\rightskip}{0pt plus 5cm}char {\bf ip}\mbox{[}17\mbox{]}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{nlb-driver_8c_c8f175c78fae68f5348eab7bcc8ca54b}


IP virtual do \hyperlink{structcluster}{cluster}. 



Definido na linha 56 do ficheiro nlb-driver.c.

Referenciado por nlb\_\-init\_\-module().